package com.atlin.cli.command;

import com.atlin.generator.file.FileGenerator;
import com.atlin.model.DataModel;
import picocli.CommandLine;
import picocli.CommandLine.Command;

import java.util.concurrent.Callable;

/**
 * @author atlin
 * @description 代码生成
 * @createDate 2024/9/23 10:04
 */
@Command(name = "generate", description = "生成代码", mixinStandardHelpOptions = true)
public class GeneratorCommand implements Callable<Integer> {

    @CommandLine.Option(names = {"-a", "--author"}, arity = "0..1", description = "作者", interactive = true, echo = true)
    private String author = "atlin";

    @CommandLine.Option(names = {"-l", "--loop"}, arity = "0..1", description = "是否循环", interactive = true, echo = true)
    private boolean loop = true;

    @CommandLine.Option(names = {"-o", "--outputText"}, arity = "0..1", description = "输出文本", interactive = true, echo = true)
    private String outputText = "sum =";


    @Override
    public Integer call() throws Exception {
        DataModel dataModel = new DataModel();
        dataModel.setAuthor(author);
        dataModel.setLoop(loop);
        dataModel.setOutputText(outputText);
        System.out.println("配置信息：" + dataModel);
        
        FileGenerator.doGenerator(dataModel);
        return 0;
    }
}
